package io.renren.sf.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.renren.sf.entity.CbBookEntity;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import io.renren.sf.dao.CbContentsDao;
import io.renren.sf.entity.CbContentsEntity;
import io.renren.sf.service.CbContentsService;


@Service("cbContentsService")
public class CbContentsServiceImpl extends ServiceImpl<CbContentsDao, CbContentsEntity> implements CbContentsService {

    @Override
    public Page<CbContentsEntity> getContentsByBookId(Map<String, Object> params) {
        String bookId = (String) params.get("bookId");
        long page = Long.parseLong((String) params.get("page"));
        long limit = Long.parseLong((String) params.get("limit"));
        Page<CbContentsEntity> contentsPage = new Page<CbContentsEntity>(page, limit);
        baseMapper.selectPage(contentsPage, new QueryWrapper<CbContentsEntity>().eq("bid", Long.parseLong(bookId)));
        return contentsPage;
    }
}